var Supplier={
	
	/*获取分页数据*/
	getPageableData:function(model,callback){
		//重新更新store
		model.test.refreshStore();
		
		var data=model.test.store.findAll();
		var dataPaginator=getPaginator(data,model.state);
				    
	    $.each(data, function() {
	    	this.UpdateTime="2016-06-14 16:33";
	    	this.Operation="[{'label':'资料修改','click':'editSupplierProfile','args':[{'field':'Code'}]},{'label':'货品管理','click':'manageSupplierProducts','args':[{'field':'Code'}]}]";
	    });
	    
	    var start=sliceStart(dataPaginator);
	    var end=sliceEnd(data,start,dataPaginator);
	    
	    var respData = _.extend({},dataPaginator) ;
	    respData.Items = data.slice(start,end);
	    
	    var resp = {
	    	    code: 0,
			    message: "成功！",
			    data: respData
	    };
	    
		callback(resp);
	},

	/*获取Model数据*/
	get:function(model){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		
		var data=model.id!=null ? getItemFormLocalStorage(model.id,model.test.store) : model.test.store.findAll();
		
		if(data!=null){
			resp.message='获取数据成功！';
			resp.data=data;
		}else{
			resp.code='-2';
			resp.message='获取数据失败！';
		}
		
		return resp;
	},
	
	/*添加*/
	add:function(model,callback){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		resp=this.validate_add(model,resp);
		if(resp.code==0){
			addItemToLocalStorage(model.id,model,model.test.store);
			resp.message='添加成功！';				
		}else{
			resp.code==-3;
		}
		
		return resp;
	},
	
	/*更新*/
	update:function(model,callback){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		resp=this.validate_update(model,resp);
		if(resp.code==0){
			updateItemToLocalStorage(model.id,model,model.test.store);
			resp.message='更新成功！';				
		}else{
			resp.code==-3;
		}
		
		return resp;
	},
	
	/*删除*/
	delete:function(model,callback){
		
		var resp={
			code:0,
			message:'',
			data:{}
		};
		resp=this.validate_delete(model,resp);
		if(resp.code==0){
			deleteItemToLocalStorage(model.id,model,model.test.store);
			resp.message='删除成功！';				
		}else{
			resp.code==-3;
		}
		
		return resp;
	},

	/*添加校验*/
	validate_add:function(model,resp){
		
		/*对象ID重复校验*/
		if(isExistInLocalStorage(model.id,model.test.store)){
			resp.code=-1;
			resp.message='供应商ID重复：'+model.id;
			
			return resp;
		}
		
		return resp;
	},
	
	/*更新校验*/
	validate_update:function(model,resp){
		
		return resp;
	},

	/*删除校验*/
	validate_delete:function(model,resp){
		/*判断是否有关联的产品*/
		if(0){
			resp.code=-1;
			resp.message='供应商'+model.toJSON().SupplierName+'还有相关的货品数据，不能进行删除操作！';
			
			return resp;
		}
		
		return resp;
	}

};